package com.dynabook.ems.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
 * BOM添加请求DTO
 */
@Data
@ApiModel(value = "BOM添加请求", description = "创建新BOM的请求参数")
public class BomAddRequest {
    /**
     * BOM编号
     */
    @ApiModelProperty(value = "BOM编号", example = "B25060001", required = true)
    private String bomNum;
    
    /**
     * 成品型号前缀
     */
    @ApiModelProperty(value = "成品型号前缀", example = "PNL13N-AAA11",required = true)
    @Pattern(regexp = "^(?i)(P|A).{11}$", message = "成品型号前缀必须是12位字符串，并且以P或A开头（不区分大小写）")
    private String productNamePrefix;
    
    /**
     * 成品型号后缀
     */
    @ApiModelProperty(value = "成品型号后缀", example = "N01",required = true)
    private String productNameSuffix;

    /**
     * 成品名称
     */
    @ApiModelProperty("成品名称")
    private String finishProductName;
    
    /**
     * 机型名称
     */
    @ApiModelProperty(value = "机型名称", example = "Pearl20", required = true)
    private String machineName;
    
    /**
     * 版本号
     */
    @ApiModelProperty(value = "版本号", example = "01",required = true)
    private String version;
    
//    /**
//     * 用户ID
//     */
//    @ApiModelProperty(value = "用户ID", example = "1001",required = true)
//    private String userId;
//
//    /**
//     * 用户名称
//     */
//    @ApiModelProperty(value = "用户名称", example = "张三",required = true)
//    private String userName;
//

    /**
     * BOM详细信息
     */
    @Valid
    private List<BomDetailItem> bomDetails;
    
    /**
     * BOM详细项
     */
    @Data
    @ApiModel(value = "BOM详细项", description = "BOM中的具体零部件信息")
    public static class BomDetailItem {
        /**
         * 样品型号
         */
        @ApiModelProperty(value = "样品型号", example = "GDM460010306", required = true)
        @NotBlank(message = "样品型号不能为空")
        private String modelType;
        
        /**
         * 样品名称
         */
        @ApiModelProperty(value = "样品名称", example = "CPU Ultra 7 258V", required = true)
        private String modelName;
        
        /**
         * 数量
         */
        @ApiModelProperty(value = "数量", example = "1", required = true)
        @NotNull(message = "数量不能为空")
        private Integer modelNumber;
        
        /**
         * 单位
         */
        @ApiModelProperty(value = "单位", example = "P",required = true)
        private String modelUnit;
        
        /**
         * 类型
         */
        @ApiModelProperty(value = "类型", example = "P",required = true)
        @NotBlank(message = "类型不能为空")
        private String modelCategory;
        
        /**
         * 备注
         */
        @ApiModelProperty(value = "备注", example = "")
        private String remark;

        @ApiModelProperty(value = "是否是第一条数据")
        private Integer isFirst =0 ;
    }
} 